*Paper: Fiscal Rules, Corruption and Electoral Accountability - Replication Files

clear all
cap log close 
set more off


**Global files
global folder "/Users/tommasogiommoni/Dropbox/Determinants of corruption/Stability pact and corruption/Replication files JOP"


********************************************************************************
****----						Dataset open 					    	----**** 
********************************************************************************

use "$folder/Data/dataset_feb2024.dta", clear

**-- Global

global controls7 proportion_female_Elected_lag av_education_Elected_lag av_age_Elected_lag  victory_margin_lag term_limit_lag 
global controls7_int  c.proportion_female_Elected_lag##i.anno c.av_education_Elected_lag##i.anno c.av_age_Elected_lag##i.anno c.victory_margin_lag##i.anno  c.term_limit_lag##i.anno

**-- Panel dataset

xtset codcom anno
fvset base 2012 anno

********************************************************************************
****----				Analysis: Event-study (first column)			----**** 
********************************************************************************

quietly xtreg corruption_exp_log_sd S##anno P i.region_year $controls7_int if abs(P)<3000 & FURs==0 & (special_region==0 | regione=="SICILIA" | regione=="SARDEGNA"), fe vce(cluster codcom)
est store reg1
quietly xtreg corruption_exp_log_sd S##anno P i.region_year $controls7_int if abs(P)<2500 & FURs==0 & (special_region==0 | regione=="SICILIA" | regione=="SARDEGNA"), fe vce(cluster codcom)
est store reg2
quietly xtreg corruption_exp_log_sd S##anno P i.region_year $controls7_int if abs(P)<2000 & FURs==0 & (special_region==0 | regione=="SICILIA" | regione=="SARDEGNA"), fe vce(cluster codcom)
est store reg3

coefplot (reg1, base offset(0) color(black) ciopts(recast(rcap) color(black black) lwidth(*0.75 *1.25)) label("BW: 3,000")) (reg2, offset(0.1) color(midblue) ciopts(recast(rcap) color(midblue midblue) lwidth(*0.75 *1.25)) label("BW: 2,500")) (reg3, offset(0.2) label("BW: 2,000")), vertical omitted keep(1.S#*.anno*)  yline(0) xline(9, lcolor(gray) lpattern(dash)) xlabel(1 "2004" 2 "2005" 3 "2006" 4 "2007" 5 "2008" 6 "2009" 7 "2010" 8 "2011" 9 "2012" 10 "2013" 11 "2014",  angle(45)) ///
ms(m) color(eltblue) ciopts(recast(rcap) color(eltblue eltblue) lwidth(*0.75 *1.25)) ylabel(-.5(0.1).5, angle(horizotal))  graphregion(color(white)) msize(small) levels(95 90) ytitle("") title("") legend(rows(1))
gr export "$folder/Figures/FigureA5_a.png" , replace 


********************************************************************************
****----					Analysis: DID (second column) 				----**** 
********************************************************************************

****---- Estimates 

quietly reghdfe corruption_exp_log_sd S##T P i.region_year $controls7_int if abs(P)<1000 & FURs==0 & (special_region==0 | regione=="SICILIA" | regione=="SARDEGNA"), absorb(codcom) cluster(codcom)
parmest, saving("$folder/Data/estimates/est_1000_FCR_z_int_spending.dta", replace)
quietly reghdfe corruption_exp_log_sd S##T P i.region_year $controls7_int if abs(P)<1200 & FURs==0 & (special_region==0 | regione=="SICILIA" | regione=="SARDEGNA"), absorb(codcom) cluster(codcom)
parmest, saving("$folder/Data/estimates/est_1200_FCR_z_int_spending.dta", replace)
quietly reghdfe corruption_exp_log_sd S##T P i.region_year $controls7_int if abs(P)<1400 & FURs==0 & (special_region==0 | regione=="SICILIA" | regione=="SARDEGNA"), absorb(codcom) cluster(codcom)
parmest, saving("$folder/Data/estimates/est_1400_FCR_z_int_spending.dta", replace)
quietly reghdfe corruption_exp_log_sd S##T P i.region_year $controls7_int if abs(P)<1600 & FURs==0 & (special_region==0 | regione=="SICILIA" | regione=="SARDEGNA"), absorb(codcom) cluster(codcom)
parmest, saving("$folder/Data/estimates/est_1600_FCR_z_int_spending.dta", replace)
quietly reghdfe corruption_exp_log_sd S##T P i.region_year $controls7_int if abs(P)<1800 & FURs==0 & (special_region==0 | regione=="SICILIA" | regione=="SARDEGNA"), absorb(codcom) cluster(codcom)
parmest, saving("$folder/Data/estimates/est_1800_FCR_z_int_spending.dta", replace)
quietly reghdfe corruption_exp_log_sd S##T P i.region_year $controls7_int if abs(P)<2000 & FURs==0 & (special_region==0 | regione=="SICILIA" | regione=="SARDEGNA"), absorb(codcom) cluster(codcom)
parmest, saving("$folder/Data/estimates/est_2000_FCR_z_int_spending.dta", replace)
quietly reghdfe corruption_exp_log_sd S##T P i.region_year $controls7_int if abs(P)<2200 & FURs==0 & (special_region==0 | regione=="SICILIA" | regione=="SARDEGNA"), absorb(codcom) cluster(codcom)
parmest, saving("$folder/Data/estimates/est_2200_FCR_z_int_spending.dta", replace)
quietly reghdfe corruption_exp_log_sd S##T P i.region_year $controls7_int if abs(P)<2400 & FURs==0 & (special_region==0 | regione=="SICILIA" | regione=="SARDEGNA"), absorb(codcom) cluster(codcom)
parmest, saving("$folder/Data/estimates/est_2400_FCR_z_int_spending.dta", replace)
quietly reghdfe corruption_exp_log_sd S##T P i.region_year $controls7_int if abs(P)<2600 & FURs==0 & (special_region==0 | regione=="SICILIA" | regione=="SARDEGNA"), absorb(codcom) cluster(codcom)
parmest, saving("$folder/Data/estimates/est_2600_FCR_z_int_spending.dta", replace)
quietly reghdfe corruption_exp_log_sd S##T P i.region_year $controls7_int if abs(P)<2800 & FURs==0 & (special_region==0 | regione=="SICILIA" | regione=="SARDEGNA"), absorb(codcom) cluster(codcom)
parmest, saving("$folder/Data/estimates/est_2800_FCR_z_int_spending.dta", replace)
quietly reghdfe corruption_exp_log_sd S##T P i.region_year $controls7_int if abs(P)<3000 & FURs==0 & (special_region==0 | regione=="SICILIA" | regione=="SARDEGNA"), absorb(codcom) cluster(codcom)
parmest, saving("$folder/Data/estimates/est_3000_FCR_z_int_spending.dta", replace)
quietly reghdfe corruption_exp_log_sd S##T P i.region_year $controls7_int if abs(P)<3200 & FURs==0 & (special_region==0 | regione=="SICILIA" | regione=="SARDEGNA"), absorb(codcom) cluster(codcom)
parmest, saving("$folder/Data/estimates/est_3200_FCR_z_int_spending.dta", replace)
quietly reghdfe corruption_exp_log_sd S##T P i.region_year $controls7_int if abs(P)<3400 & FURs==0 & (special_region==0 | regione=="SICILIA" | regione=="SARDEGNA"), absorb(codcom) cluster(codcom)
parmest, saving("$folder/Data/estimates/est_3400_FCR_z_int_spending.dta", replace)
quietly reghdfe corruption_exp_log_sd S##T P i.region_year $controls7_int if abs(P)<3600 & FURs==0 & (special_region==0 | regione=="SICILIA" | regione=="SARDEGNA"), absorb(codcom) cluster(codcom)
parmest, saving("$folder/Data/estimates/est_3600_FCR_z_int_spending.dta", replace)
quietly reghdfe corruption_exp_log_sd S##T P i.region_year $controls7_int if abs(P)<3800 & FURs==0 & (special_region==0 | regione=="SICILIA" | regione=="SARDEGNA"), absorb(codcom) cluster(codcom)
parmest, saving("$folder/Data/estimates/est_3800_FCR_z_int_spending.dta", replace)
quietly reghdfe corruption_exp_log_sd S##T P i.region_year $controls7_int if abs(P)<4000 & FURs==0 & (special_region==0 | regione=="SICILIA" | regione=="SARDEGNA"), absorb(codcom) cluster(codcom)
parmest, saving("$folder/Data/estimates/est_4000_FCR_z_int_spending.dta", replace)

****---- Figures

preserve
use "$folder/Data/estimates/est_1000_FCR_z_int_spending.dta", clear
append using "$folder/Data/estimates/est_1200_FCR_z_int_spending.dta"
append using "$folder/Data/estimates/est_1400_FCR_z_int_spending.dta"
append using "$folder/Data/estimates/est_1600_FCR_z_int_spending.dta"
append using "$folder/Data/estimates/est_1800_FCR_z_int_spending.dta"
append using "$folder/Data/estimates/est_2000_FCR_z_int_spending.dta"
append using "$folder/Data/estimates/est_2200_FCR_z_int_spending.dta"
append using "$folder/Data/estimates/est_2400_FCR_z_int_spending.dta"
append using "$folder/Data/estimates/est_2600_FCR_z_int_spending.dta"
append using "$folder/Data/estimates/est_2800_FCR_z_int_spending.dta"
append using "$folder/Data/estimates/est_3000_FCR_z_int_spending.dta"
append using "$folder/Data/estimates/est_3200_FCR_z_int_spending.dta"
append using "$folder/Data/estimates/est_3400_FCR_z_int_spending.dta"
append using "$folder/Data/estimates/est_3600_FCR_z_int_spending.dta"
append using "$folder/Data/estimates/est_3800_FCR_z_int_spending.dta"
append using "$folder/Data/estimates/est_4000_FCR_z_int_spending.dta"

qui keep if parm=="1.S#1.T"
qui gen sign=stderr*1.654
qui gen min90=estimate-sign
qui gen max90=estimate+sign
qui keep estimate min95 max95 min90 max90

qui gen h=.
qui replace h=1000 if _n==1
qui replace h=1200 if _n==2
qui replace h=1400 if _n==3
qui replace h=1600 if _n==4
qui replace h=1800 if _n==5
qui replace h=2000 if _n==6
qui replace h=2200 if _n==7
qui replace h=2400 if _n==8
qui replace h=2600 if _n==9
qui replace h=2800 if _n==10
qui replace h=3000 if _n==11
qui replace h=3200 if _n==12
qui replace h=3400 if _n==13
qui replace h=3600 if _n==14
qui replace h=3800 if _n==15
qui replace h=4000 if _n==16

twoway rcap min95 max95 h, color(black black) lwidth(*0.75) ||rcap min90 max90 h, color(black black) lwidth(*1.25) || connected estimate h, graphregion(color(white)) lpattern(dash) lcolor(grey) mcolor(black) ///
ylabel(-.5(0.1).5, angle(horizontal)) xlabel(1000(200)4000,  angle(45)) legend(off) title("") xtitle("Bandwidth") yline(0)
gr export "$folder/Figures/FigureA5_b.png" , replace 
restore
